<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property string $order_no 订单号
 * @property integer $user_id 用户ID
 * @property string $price 订单金额
 * @property integer $type 订单类型
 * @property integer $pay_way 支付方式
 * @property string $pay_time 支付时间
 * @property string $receive_contact 收货人
 * @property string $receive_mobile 收货人联系电话
 * @property string $receive_address 收货人地址
 * @property string $receive_time 收货时间
 * @property string $express_company 物流公司
 * @property string $express_no 物流单号
 * @property string $express_price 物流费用
 * @property string $shipping_time 发货时间
 * @property string $created_time 创建时间
 */
class Order extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_orders';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    const PAY_TYPE_WECHAT = 'wechat';

    const PAY_TYPE_BALANCE = 'balance';

    const STATUS_WAITING_PAY = 1;

    const STATUS_WAITING_SHIPPING = 2;

    const STATUS_WAITING_RECEIVE = 3;

    const STATUS_FINISH = 4;

    const STATUS_CANCEL = 5;

    const STATUS_AFTER_SALES = 6;

    const STATUS_COMMENT = 7;

    CONST STATUS_WAITING_FINISH = 8;

    CONST STATUS_WAITING_GET = 9;

    const TYPE_GOODS = 1;

    const TYPE_GIFT = 2;

    const TYPE_TEXT = [
        self::TYPE_GOODS => '普通商品',
        self::TYPE_GIFT => '报单商品'
    ];

    public static function getStatusText($order)
    {

        switch ($order['status']) {
            case self::STATUS_WAITING_PAY:
                return '待支付';
            case self::STATUS_WAITING_SHIPPING:
                return '待发货';
            case self::STATUS_WAITING_RECEIVE:
                return '待收货';
            default:
            case self::STATUS_FINISH:
                return '待评价';
            case self::STATUS_CANCEL:
                return '已取消';
            case self::STATUS_COMMENT:
                return '已完成';
            case self::STATUS_WAITING_GET:
                return '待取件';
            case self::STATUS_AFTER_SALES:
                return '已售后';
        }
    }

    public static function getWallet($payWay)
    {
        switch ($payWay) {
            case self::PAY_TYPE_BALANCE:
                return '积分余额';
            case self::PAY_TYPE_WECHAT:
                return '微信钱包';
        }
    }
}
